package com.feilong.edgeAI.ui;


import android.content.Intent;

import android.graphics.Color;
import android.os.Bundle;

import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;

import androidx.viewpager.widget.ViewPager;
import com.aiibt.common.util.Constant;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.feilong.edgeAI.R;
import com.feilong.edgeAI.model.FeilongRespone;

import com.feilong.edgeAI.remind.room.ui.CycleFragment;
import com.feilong.edgeAI.remind.room.ui.EditDialog;
import com.feilong.edgeAI.remind.room.ui.AddRemindActivity;
import com.feilong.edgeAI.remind.room.ui.InquiryDialog;
import com.feilong.edgeAI.remind.room.ui.SingleFragment;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.google.gson.Gson;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by【仿脑科技】
 *
 * @Author: potato
 * @CreateDate: 2024/2/4 15:28
 */
@Route(path = Constant.ACTIVITY_URL_REMIND)
public class RemindActivity extends AppCompatActivity{
    private static final String TAG = "RemindActivity";
    @Autowired
    public FeilongRespone feilongRespone;
    private SingleFragment fragment_single;
    private CycleFragment fragment_cycle;
    private ViewPager viewPager;
    private TabLayout tabLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_remind);

        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);

        initView();
    }


    private void initView() {
        tabLayout = findViewById(R.id.tablayout);
        viewPager = findViewById(R.id.viewpager);

        findViewById(R.id.iv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        List<String> tabName = new ArrayList<>();
        List<Fragment> fragments = new ArrayList<>();
        tabName.clear();
        tabName.add("单次提醒");
        tabName.add("循环提醒");
        fragment_single = new SingleFragment();
        fragment_cycle = new CycleFragment();
        fragments.add(fragment_single);
        fragments.add(fragment_cycle);

        FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @NonNull
            @Override
            public Fragment getItem(int position) {
                return fragments.get(position);
            }

            @Override
            public int getCount() {
                return fragments.size();
            }
        };

        viewPager.setAdapter(adapter);

        tabLayout.setupWithViewPager(viewPager);
        tabLayout.getTabAt(0).setText("单次提醒");
        tabLayout.getTabAt(1).setText("循环提醒");

        findViewById(R.id.add_remind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

               startActivity(new Intent(RemindActivity.this, AddRemindActivity.class));

              // findData();
            }
        });
    }

    private void findData() {

        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat sdf = null;

        sdf = new SimpleDateFormat("yyyy-M-dd");
        String currentDate = sdf.format(date);
        Log.i(TAG, "findData: "+currentDate);

        Bundle mBundle = new Bundle();
        InquiryDialog mDialog = new InquiryDialog();
        mBundle.putString("flag",currentDate);
        mDialog.show(RemindActivity.this, mBundle, "edit");

    }

}
